﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Data;
using ReportBusiness;

public class AuthorityControl
{
    public bool isHaveAuthorty(string httpUrl,EmployeeInfoDTO dto)
    {
        // 未登录时，输入url强制跳转至登录页
        if (dto.Employeeid == null)
        {
            return false;
        }

        // 登录后，输入没有权限访问的URL时，强制跳转登录页
        string[] url = httpUrl.Split('/');
        string pageUrl = url[url.Length - 1].ToString();
        if (pageUrl.Contains("?"))
        {
            pageUrl = pageUrl.Split('?')[0].ToString();
        }
        string strFilter = string.Format("pageurl = '{0}' ", pageUrl);

        DataTable dtPagesCanSee = dto.DtPages;
        DataRow[] tmpRows = dtPagesCanSee.Select(strFilter);

        if (tmpRows.Length == 0)
        {
            return false;
        }
        return true;
    }
}